<!DOCTYPE html>
<html>

<head>
    <title>RoveCoder集约化管理平台</title>

    <meta name="keywords" content="" />

    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="/static/uc/css/theme.css" rel="stylesheet">
    <link href="/static/uc/lib/layui/css/layui.css" rel="stylesheet">
    <link href="/static/uc/css/login.css" rel="stylesheet">
    <style>
        <?php
        if (isset($SyscnfUcenterinfo) && $SyscnfUcenterinfo && $SyscnfUcenterinfo['welcomepic']) {
        ?>.xcpic {
            background-image: url('<?php echo $SyscnfUcenterinfo['welcomepic'] ?>');
        }

        <?php
        }
        ?>
    </style>
</head>

<body>
    <div class="loginbox">
        <div class="loginform">
            <h2>找回密码</h2>
            <div style="padding-top: 10px;">
                <?php
                $forgetpwd = explode(',', $config['forgetpwd']);

                ?>
                <form class="layui-form" lay-filter="login-form">

                    <div class="layui-tab layui-tab-brief">
                        <ul class="layui-tab-title">
                            <?php
                            if (in_array(1, $forgetpwd)) {
                            ?>
                                <li class="layui-this">手机找回</li>
                            <?php
                            }
                            ?>
                            <?php
                            if (in_array(2, $forgetpwd)) {
                            ?>
                                <li class="<?php echo count($forgetpwd) == 1 ? 'layui-this' : '' ?>">邮箱找回</li>
                            <?php
                            }
                            ?>
                        </ul>

                        <div class="layui-tab-content">
                            <div class="layui-form-item">
                                <label class="layui-form-label">用户名：</label>
                                <div class="layui-input-block">
                                    <input type="text" name="username" id="username" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>

                            </div>
                            <?php
                            if (in_array(1, $forgetpwd)) {
                            ?>
                                <div class="layui-tab-item layui-show rc-pagepadding" submit_forgetpwd="1">



                                    <div class="layui-form-item">
                                        <label class="layui-form-label">手机号：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="phone" id="phone" placeholder="请输入" autocomplete="off" class="layui-input">
                                        </div>

                                    </div>




                                </div>
                            <?php
                            } ?>


                            <?php
                            if (in_array(2, $forgetpwd)) {
                            ?>
                                <div class="layui-tab-item  rc-pagepadding <?php echo count($forgetpwd) == 1 ? 'layui-show' : '' ?>" submit_forgetpwd="2">



                                    <div class="layui-form-item">
                                        <label class="layui-form-label">邮箱：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="email" id="email" placeholder="请输入" autocomplete="off" class="layui-input">
                                        </div>

                                    </div>



                                </div>
                            <?php
                            } ?>





                        </div>

                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline" style="position: relative;margin-right:0">
                            <div class="captchbox" id="captchbox">
                                <div class="" style="padding: 0!important;">
                                    <img src="" id="captchaimg" width="289" height="60" />
                                </div>
                            </div>



                            <label class="layui-form-label">验证码：</label>
                            <div class="layui-input-inline layui-input-wrap" style="width: 202px;">
                                <input type="text" id="realcaptcha" name="realcaptcha" lay-verify="required" autocomplete="off" lay-reqtext="请填写短信验证" lay-affix="clear" class="layui-input " />
                            </div>

                            <div class="layui-form-mid " style="padding: 0!important;margin-right:0!important">
                                <button type="button" class="layui-btn " id="showcaptch">获取验证码</button>
                            </div>


                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="forgetpwd_submit">找回</button>
                        </div>

                    </div>


                </form>
            </div>
            <hr>
            <div class="copyright">
                <p> © <?php echo date('Y') ?> RC集约化管理平台 . All rights RoveCoder </p>
            </div>
        </div>
        <div class="xcpic">

        </div>
    </div>
    <script src="/static/admin/lib/jquery/jquery.min.js"></script>
    <script src="/static/uc/lib/layui/layui.js"></script>
    <script src="/static/uc/lib/toastr/toastr.min.js"></script>
    <link href="/static/uc/lib/toastr/toastr.min.css" rel="stylesheet">
    <script src="/static/uc/js/rovecoder.js"></script>
    <script>
        layui.use(function() {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            var element = layui.element;

            $('#captchaimg').click(function() {
                $('#captchaimg').attr('src', '/uc/Logreg/captcha?width=' + $('#captchaimg').attr('width') + '&height=' + $('#captchaimg').attr('height') + '&t=' + Math.random());
            });

            $('#showcaptch').click(function() {
                if (!$('#captchbox').is(":visible")) {
                    $('#captchaimg').attr('src', '/uc/Logreg/captcha?width=' + $('#captchaimg').attr('width') + '&height=' + $('#captchaimg').attr('height') + '&t=' + Math.random());
                    $('#captchbox').show();
                }
            });

            $(document).click(function(event) {
                var event = event.srcElement ? event.srcElement : event.target;

                if (event.id != 'showcaptch' && event.id != 'captcha' && event.id != 'captchaimg' && event.id != 'sendsms' && event.id != 'captchbox' && event.id != 'realcaptcha') {
                    $('#captchbox').hide();
                }

            });



            form.on('submit(forgetpwd_submit)', function(data) {

                var submit_forgetpwd = $('.layui-show').attr('submit_forgetpwd');
                var postdata = data.field;
                postdata.submit_forgetpwd = submit_forgetpwd;
                $.ajax({
                    url: '/uc/Logreg/forgetpwd', //请求路径
                    type: "POST", //请求方式
                    data: postdata, // 默认写法
                    success: function(data) {
                        if (data.code == 0) {
                            toastr_success("密码已发送" + (submit_forgetpwd == 1 ? '你的手机' : '你的邮箱'), function() {

                            });
                        } else {
                            toastr_error(data.message);


                        }
                    },
                    error: function() {

                    },

                });
            });

        });
    </script>
</body>

</html>